pull: Avoid leaking signal handlers across fetch requests
authorColin Walters <walters@verbum.org>
Tue, 30 Jun 2015 01:56:03 +0000 (21:56 -0400)
committerColin Walters <walters@verbum.org>
Tue, 30 Jun 2015 01:56:03 +0000 (21:56 -0400)
libsoup will cache sessions, so it might be the case that we get a
reused session when pulling from the same repo multiple times in one
process.

In this case we were leaking signal connections, which caused
callbacks into freed memory with bad consequences.

Fix it by tying the signal connection to the object lifetime.

src/libostree/ostree-fetcher.c

index ee7498255a5a9095b3990d7594574bbd131f1e94..46b8c44ae2603c0b071ae8529a76415f502705fb 100644 (file)
@@ -201,10 +201,10 @@ _ostree_fetcher_init (OstreeFetcher *self)
 
   self->max_outstanding = 3 * max_conns;
 
-  g_signal_connect (self->session, "request-started",
-                    G_CALLBACK (on_request_started), self);
-  g_signal_connect (self->session, "request-unqueued",
-                    G_CALLBACK (on_request_unqueued), self);
+  g_signal_connect_object (self->session, "request-started",
+                           G_CALLBACK (on_request_started), self, 0);
+  g_signal_connect_object (self->session, "request-unqueued",
+                           G_CALLBACK (on_request_unqueued), self, 0);
   
   self->sending_messages = g_hash_table_new_full (NULL, NULL, NULL,
                                                   (GDestroyNotify)g_object_unref);